cmake_minimum_required(VERSION 3.15)
project(demo LANGUAGES CXX)

#================ 验证确实使用了 conan2 提供的 cmake 和 ninja
message(STATUS "[ymy]CMake path: ${CMAKE_COMMAND}; Version: ${CMAKE_VERSION}")
# 在 CMakeLists.txt 中
if(CMAKE_GENERATOR STREQUAL "Ninja")
  find_program(NINJA_EXECUTABLE ninja REQUIRED)
  execute_process(
    COMMAND "${NINJA_EXECUTABLE}" --version
    OUTPUT_VARIABLE NINJA_VERSION
    OUTPUT_STRIP_TRAILING_WHITESPACE
  )
  message(STATUS "[ymy]Ninja path: ${NINJA_EXECUTABLE}; Version: ${NINJA_VERSION}")
endif()


# xxxxxxxxxxxxxxxxxxxxxxxxxxx add target
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# 为可执行文件设置 RPATH, 需要位于 add_executable 之前
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH OFF)

find_package(fmt CONFIG REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(spdlog REQUIRED)

set(MYEXE ${PROJECT_NAME})
add_executable(${MYEXE} src/main.cpp)
target_link_libraries(${MYEXE} PRIVATE fmt::fmt Eigen3::Eigen spdlog::spdlog)


#===================================== 安装(打包) exe, .so, 发给用户
include(cmake/install.cmake)

## cmake --install build --component conan_runtime --prefix /opt/myapp
##--- cpack 打包命令
## cpack -G ZIP -C Debug --config build/Debug/CPackConfig.cmake